package model;

/**
 * @author Colin
 * 
 * The Velocity class is responsible for the velocity of Ammo
 *
 */
public class Velocity {
	private float x1;
	private float y1;
	private float x2;
	private float y2;
	
	float speed;
	
	public Velocity( float x1, float y1, float x2, float y2, float speed ){
		this.x1 = x1;
		this.y1 = y1;
		this.x2 = x2;
		this.y2 = y2;
		
		this.speed = speed;
	}
	
	public float getX1(){
		return x1;
	}
	public float getY1(){
		return y1;
	}
	public float getX2(){
		return x2;
	}
	public float getY2(){
		return y2;
	}
	public float getDx(){
		return x2 - x1;
	}
	public float getDy(){
		return y2-y1;		//positive when moving down the map, since y increases downwards
	}
	public float getAngle(){
		//System.out.print("IN VELOCITY:getAngle() dy="+getDy()+" dx="+getDx()+" angle1="+(float)Math.atan((-getDy())/getDx()));
		float angle = (float)Math.atan((-getDy())/getDx());
		if(getDx() < 0) angle += Math.PI;	//atan returns an angle between -PI/2 and PI/2. This corrects for that.
		//System.out.println(" angle2="+angle);
		return angle;
	}
	
	public float getSpeed(){
		return speed;
	}
}
